package com.share.user.api.factory;

import com.share.common.core.domain.R;
import com.share.common.core.domain.Users;
import com.share.user.api.domain.UpdateUserLogin;
import com.share.user.api.domain.UserInfo;
import com.share.user.api.domain.UserLogin;
import com.share.user.api.model.RemoteShareUserService;
import lombok.extern.log4j.Log4j2;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;


@Log4j2
@Component
public class RemoteShareUserServiceFallbackFactory implements FallbackFactory<RemoteShareUserService> {

    @Override
    public RemoteShareUserService create(Throwable cause) {
        log.error("用户服务调用失败:{}", cause.getMessage());
        return new RemoteShareUserService() {
            @Override
            public R<UserInfo> getUsers(String code) {
                return R.fail("获取用户信息失败");
            }

            @Override
            public R<Users> updateUserLogin(@RequestBody UserLogin userLogin) {
                return R.fail("更新用户信息失败");
            }
        };
    }
}
